home *** CD-ROM | disk | FTP | other *** search
/ 500 MB Nyheder Direkte fra Internet 5 / 500 MB nyheder direkte fra internet CD 5.iso / start / zipped / os2 / progtool / prnt3.exe / Print.C < prev    next >
C/C++ Source or Header  |  1995-04-09  |  6KB  |  155 lines

  1. #pragma    title("Printer Driver  --  Version 3  --  (Print.C)")
  2. #pragma    subtitle("   main Entry Poiint - Interface Definitions")
  3.  
  4. #pragma    info(noext, nopar)
  5.  
  6. #define    INCL_DOS           /* Include OS/2 DOS Kernal        */
  7. #define    INCL_GPI           /* Include OS/2 PM GPI Interface    */
  8. #define    INCL_WIN           /* Include OS/2 PM Windows Interface    */
  9.  
  10. #include <os2.h>
  11.  
  12. #include "appdefs.h"
  13. #include "prnsetup.h"
  14.  
  15. /* This    module contains    main function for the Print Driver application.    */
  16.  
  17. /* The executable is created using the following options:        */
  18. /*                                    */
  19. /* Option           Value                        */
  20. /* ------           -----                        */
  21. /* Op Sys           OS/2 PM Executable                */
  22. /* Optimization           Maximize                        */
  23. /* Compile Type           Subsystem                    */
  24. /* CPU               80486                        */
  25. /* Warning Level       3                        */
  26. /*                                    */
  27. /* Equivalent command line invocation:                    */
  28. /*                                    */
  29. /*  Icc    -C -G4 -O+ -Rn -W3 Print.C          IBM C    Set++        */
  30. /*  BCC    -Ox -v-    -w -c Print.C              Borland C++ for OS/2    */
  31. /*  Wcl386 -c -ms -4s -s -ox -zp4 -w3 Print.C      WATCOM C/C++        */
  32.  
  33. /* Filename:   Print.C                            */
  34.  
  35. /*  Version:   1                            */
  36. /*  Created:   1995-03-07                        */
  37. /*  Revised:   1995-03-07                        */
  38.  
  39. /* Routines:   int main( );                        */
  40.  
  41. /************************************************************************/
  42. /************************************************************************/
  43. /************************************************************************/
  44. /* DISCLAIMER OF WARRANTIES:                        */
  45. /* -------------------------                        */
  46. /* The following [enclosed] code is sample code    created    by IBM        */
  47. /* Corporation and Prominare Inc.  This    sample code is not part    of any    */
  48. /* standard IBM    product    and is provided    to you solely for the purpose    */
  49. /* of assisting    you in the development of your applications.  The code    */
  50. /* is provided "AS IS",    without    warranty of any    kind.  Neither IBM nor    */
  51. /* Prominare shall be liable for any damages arising out of your    */
  52. /* use of the sample code, even    if they    have been advised of the    */
  53. /* possibility of such damages.                        */
  54. /************************************************************************/
  55. /************************************************************************/
  56. /************************************************************************/
  57. /*               D I S C L A I M E R                */
  58. /* This    code is    provided on an as is basis with    no implied support.    */
  59. /* It should be    considered freeware that cannot    be rebundled as        */
  60. /* part    of a larger "*ware" offering without our consent.        */
  61. /************************************************************************/
  62. /************************************************************************/
  63. /************************************************************************/
  64.  
  65. /* Copyright ╕ International Business Machines Corp., 1995.        */
  66. /* Copyright ╕ 1995  Prominare Inc.  All Rights    Reserved.        */
  67.  
  68. /* --------------------------------------------------------------------    */
  69.  
  70. PSZ pszPrnSetupClassName = (PSZ)"PrnSetup";
  71. PSZ pszToolBarClassName     = (PSZ)"ToolBar";
  72.  
  73.  
  74. INT main(INT argc, CHAR    *argv[ ])
  75.  
  76. {
  77. QMSG  qmsg;               /* PM Message Queue Holder        */
  78.  
  79. #if defined(INCL_VALAPI)
  80.  
  81. ValInitialize("Print Example", NULL, VL_VIEWPORT);
  82.  
  83. #endif
  84.  
  85.                /* Initialize the program for PM    and create the    */
  86.                /* message queue                    */
  87.  
  88. hmqPrnSetup = WinCreateMsgQueue(hAB = WinInitialize(0UL), 0L);
  89.  
  90.                /* Register the window class            */
  91.  
  92. if ( !WinRegisterClass(hAB, pszPrnSetupClassName, (PFNWP)PrintDriverWndProc,
  93.                CS_SYNCPAINT | CS_SIZEREDRAW | CS_CLIPCHILDREN, 0UL) )
  94.    return(0);
  95.                /* Register the window class            */
  96.  
  97. if ( !WinRegisterClass(hAB, pszToolBarClassName, (PFNWP)ToolBarWndProc,
  98.                CS_SYNCPAINT | CS_SIZEREDRAW, 0UL) )
  99.    return(0);
  100.                /* Get default printer to use            */
  101.  
  102. if ( PrnCreatePrinterList(&prn)    )
  103.    prn.hAB = hAB;
  104.                /* Create the main program window        */
  105.  
  106. if ( !(hwndPrnSetupFrame = CreateStdWindow(HWND_DESKTOP, WS_VISIBLE,
  107.                        FCF_NOBYTEALIGN | FCF_TASKLIST |
  108.                        FCF_TITLEBAR    | FCF_ICON |
  109.                        FCF_SYSMENU | FCF_MENU | FCF_MINMAX |
  110.                        FCF_SIZEBORDER,
  111.                        pszPrnSetupClassName, (PSZ)"Print Driver", 0L,
  112.                        (HMODULE)NULL, WIN_PRINTDRIVER, &hwndPrnSetup, 20, 40, 200, 125)) )
  113.    return(0);
  114.  
  115. InitApp(hwndPrnSetupFrame, hwndPrnSetup, "Print Font Example");
  116.  
  117.                /* Create Help instance and associate it    with    */
  118.                /* the programs frame window            */
  119.  
  120. if ( (hwndHelp = WinCreateHelpInstance(hAB, &helpinit))    != (HWND)NULL )
  121.    WinAssociateHelpInstance(hwndHelp, hwndPrnSetupFrame);
  122.                /* Get and dispatch the message to program    */
  123.                /* windows                    */
  124.  
  125. while (    WinGetMsg(hAB, &qmsg, (HWND)NULL, 0UL, 0UL) )
  126.    WinDispatchMsg(hAB, &qmsg);
  127.  
  128.                /* Destroy the printer list            */
  129. if ( prn.hAB !=    0UL )
  130.    PrnDestroyPrinterList(&prn);
  131.  
  132.                /* Destroy the Help instance associated with the    */
  133.                /* the programs frame window            */
  134.  
  135. if ( hwndHelp )
  136.    {
  137.    WinAssociateHelpInstance((HWND)NULL,    hwndPrnSetupFrame);
  138.    WinDestroyHelpInstance(hwndHelp);
  139.    }
  140.  
  141.                /* Have received    a WM_QUIT, start the program    */
  142.                /* shutdown by destroying the program windows    */
  143.                /* and destroying the message queue        */
  144.  
  145. WinDestroyWindow(hwndPrnSetupFrame);
  146.  
  147. WinDestroyMsgQueue(hmqPrnSetup);
  148.  
  149.                /* Notify PM that main program thread not needed    */
  150.                /* any longer                    */
  151. WinTerminate(hAB);
  152.                /* Exit back to OS/2 cleanly            */
  153. return(0);
  154. }
  155.